1 /*
2  * Copyright (C) 2010 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 /**
18  * @addtogroup Storage
19  * @{
20  */
21 
22 /**
23  * @file storage_manager.h
24  */
25 
26 module android.ndk.storage_manager;
27 
28 import arsd.jni;
29 import android.ndk;
30 
31 extern (C):
32 nothrow:
33 @nogc:
34 
35 struct AStorageManager;
36 /**
37  * {@link AStorageManager} manages application OBB storage, a pointer
38  * can be obtained with AStorageManager_new().
39  */
40 
41 /**
42  * The different states of a OBB storage passed to AStorageManager_obbCallbackFunc().
43  */
44 enum
45 {
46     /**
47      * The OBB container is now mounted and ready for use. Can be returned
48      * as the status for callbacks made during asynchronous OBB actions.
49      */
50     AOBB_STATE_MOUNTED = 1,
51 
52     /**
53      * The OBB container is now unmounted and not usable. Can be returned
54      * as the status for callbacks made during asynchronous OBB actions.
55      */
56     AOBB_STATE_UNMOUNTED = 2,
57 
58     /**
59      * There was an internal system error encountered while trying to
60      * mount the OBB. Can be returned as the status for callbacks made
61      * during asynchronous OBB actions.
62      */
63     AOBB_STATE_ERROR_INTERNAL = 20,
64 
65     /**
66      * The OBB could not be mounted by the system. Can be returned as the
67      * status for callbacks made during asynchronous OBB actions.
68      */
69     AOBB_STATE_ERROR_COULD_NOT_MOUNT = 21,
70 
71     /**
72      * The OBB could not be unmounted. This most likely indicates that a
73      * file is in use on the OBB. Can be returned as the status for
74      * callbacks made during asynchronous OBB actions.
75      */
76     AOBB_STATE_ERROR_COULD_NOT_UNMOUNT = 22,
77 
78     /**
79      * A call was made to unmount the OBB when it was not mounted. Can be
80      * returned as the status for callbacks made during asynchronous OBB
81      * actions.
82      */
83     AOBB_STATE_ERROR_NOT_MOUNTED = 23,
84 
85     /**
86      * The OBB has already been mounted. Can be returned as the status for
87      * callbacks made during asynchronous OBB actions.
88      */
89     AOBB_STATE_ERROR_ALREADY_MOUNTED = 24,
90 
91     /**
92      * The current application does not have permission to use this OBB.
93      * This could be because the OBB indicates it's owned by a different
94      * package. Can be returned as the status for callbacks made during
95      * asynchronous OBB actions.
96      */
97     AOBB_STATE_ERROR_PERMISSION_DENIED = 25
98 }
99 
100 /**
101  * Obtains a new instance of AStorageManager.
102  */
103 AStorageManager* AStorageManager_new ();
104 
105 /**
106  * Release AStorageManager instance.
107  */
108 void AStorageManager_delete (AStorageManager* mgr);
109 
110 /**
111  * Callback function for asynchronous calls made on OBB files.
112  *
113  * "state" is one of the following constants:
114  * - {@link AOBB_STATE_MOUNTED}
115  * - {@link AOBB_STATE_UNMOUNTED}
116  * - {@link AOBB_STATE_ERROR_INTERNAL}
117  * - {@link AOBB_STATE_ERROR_COULD_NOT_MOUNT}
118  * - {@link AOBB_STATE_ERROR_COULD_NOT_UNMOUNT}
119  * - {@link AOBB_STATE_ERROR_NOT_MOUNTED}
120  * - {@link AOBB_STATE_ERROR_ALREADY_MOUNTED}
121  * - {@link AOBB_STATE_ERROR_PERMISSION_DENIED}
122  */
123 alias AStorageManager_obbCallbackFunc = void function (const(char)* filename, const int state, void* data);
124 
125 /**
126  * Attempts to mount an OBB file. This is an asynchronous operation.
127  */
128 void AStorageManager_mountObb (
129     AStorageManager* mgr,
130     const(char)* filename,
131     const(char)* key,
132     AStorageManager_obbCallbackFunc cb,
133     void* data);
134 
135 /**
136  * Attempts to unmount an OBB file. This is an asynchronous operation.
137  */
138 void AStorageManager_unmountObb (
139     AStorageManager* mgr,
140     const(char)* filename,
141     const int force,
142     AStorageManager_obbCallbackFunc cb,
143     void* data);
144 
145 /**
146  * Check whether an OBB is mounted.
147  */
148 int AStorageManager_isObbMounted (AStorageManager* mgr, const(char)* filename);
149 
150 /**
151  * Get the mounted path for an OBB.
152  */
153 const(char)* AStorageManager_getMountedObbPath (AStorageManager* mgr, const(char)* filename);
154 
155 // ANDROID_STORAGE_MANAGER_H
156 
157 /** @} */